(function(){
	function $(id){
		return document.getElementById(id);
	}
	window.$=$;
	$.init=function(){
		try{return new XMLHttpRequest();}catch(e){};
		try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){}
		alert('请更换浏览器');
		return false;
	}
	$.get=function(url,data,callback,type){
		var xhr=$.init();
		xhr.open('get',url+'?'+data);
		xhr.setRequestHeader("If-Modified-Since","0");
		xhr.send(null);
		xhr.onreadystatechange=function(){
			if(xhr.readyState==4 && xhr.status==200){
				if(type=='xml'){
					callback(xhr.responseXML);
				}else if(type=='json'){
					callback(eval('('+xhr.responseText+')'));
				}else{
					callback(xhr.responseText);
				}
			}
		}
	}

	$.post=function(url,data,callback,type){
		$.open('post',url);
		$.setRequestHeader("If-Modified-Since","0");
		$.send(data);
		$.onreadystatechange=function(){
			if($.readyState==4&&$.status==200){
				if(type=='xml'){
					callback($.responseXML);
				}else if(type=='json'){
					callback(eval('('+$.responseText+')'));
				}else{
					callback($.responseText);
				}
			}
		}
	}

})();